<div id="page-heading"><h1><?php echo lang('tours.manage_title'); ?></h1></div>
<?php $this->load->view('partials/notices'); ?>

<form method="post" action="<?php echo site_url('admin/catalog/search_tours');?>">	
<table cellspacing="0" cellpadding="0" border="0" id="id-form">
		<tbody><tr>
			<td><?php echo form_input('keyword', $keyword, 'class="inp-form" name="keyword" id="keyword"'); ?></td>
			<td><?php echo form_dropdown('type', array('name_type' => lang('tours.name_label'), 'serial_type' => lang('tours.serial') ), array($type), 'class="select_box" style="width:150px;"'); ?></td>
			<td><?php echo lang('tours.available_label'); ?>:</td>
			<td><?php echo form_dropdown('available', array('all' => lang('global:select-all'), 1 => lang('global:yes'), 0 => lang('global:no') ), array($available), 'class="select_box" style="width:150px;"'); ?></td>
			<td><?php echo lang('tours.channel_id'); ?>:</td>
			<?php 
			$channels_options = array();
			foreach($channels as $channel_opt){
				$channels_options[$channel_opt->id] = empty($channel_opt->name)? lang('global:empty'): $channel_opt->name;
			}
			?>
			<td><?php echo form_dropdown('channel', array(0 => lang('global:select-all')) + $channels_options, array($channel), 'class="select_box" style="width:150px;"'); ?></td>
			<td valign="top">
			<input type="submit" class="form-submit" value="">
		</td>
		</tr>
	</tbody></table>
	</form>
<?php if ($tours): ?>	
<?php echo form_open('admin/catalog/action_tour', 'id="mainform"');?>
<table cellspacing="0" cellpadding="0" border="0" width="100%" id="product-table">
				<tbody>
				<tr>
				<?php if (group_has_role('catalog', 'delete_tour')): ?>
					<th class="table-header-check"><a id="toggle-all" ></a> </th>
				<?php endif;?>
				
					<th class="table-header-repeat line-left"><a href="javascript:void(0);"><?php echo lang('tours.name_label'); ?></a></th>
					<th class="table-header-repeat line-left"><a href="javascript:void(0);"><?php echo lang('tours.price'); ?></a></th>
					<th class="table-header-repeat line-left"><a href="javascript:void(0);"><?php echo lang('tours.discountprice'); ?></a></th>
					<th class="table-header-repeat line-left"><a href="javascript:void(0);"><?php echo lang('tours.serial'); ?></a></th>
					<th class="table-header-repeat line-left"><a href="javascript:void(0);"><?php echo lang('tours.days'); ?></a></th>
					<th class="table-header-repeat line-left"><a href="javascript:void(0);"><?php echo lang('tours.getin_type'); ?></a></th>
					<th class="table-header-repeat line-left"><a href="javascript:void(0);"><?php echo lang('tours.channel_id'); ?></a></th>
					<th class="table-header-repeat line-left"><a href="javascript:void(0);"><?php echo lang('tours.type'); ?></a></th>
					<th class="table-header-repeat line-left"><a href="javascript:void(0);"><?php echo lang('global:actions')?></a></th>
				</tr>
				<?php foreach ($tours as $key => $tour): ?>
				<tr <?php if($key%2 == 0):?>class="alternate-row"<?php endif;?>>
					<?php if (group_has_role('catalog', 'delete_tour')): ?>
						<td><?php echo form_checkbox('action_to[]', $tour->id); ?></td>
					<?php endif; ?>
					<td><?php echo anchor('admin/catalog/edit_tour/' . $tour->id, $tour->name, 'title="' . $tour->name .'" class="folder-hash"'); ?></td>
					<td><?php echo $tour->price?></td>
					<td><?php echo $tour->discountprice?></td>
					<td><?php echo $tour->serial?></td>
					<td><?php echo $tour->days?></td>
					<td><?php echo $tour->getin_type?></td>
					<td><?php 
					foreach($channels as $channel){
						if($tour->channel_id == $channel->id){
							echo $channel->name;
							break;
						}
					}
					?></td>
					<td><?php echo$tour->type?></td>
					<td class="options-width">
					<?php if (group_has_role('catalog', 'edit_tour')): ?>
						<?php echo anchor('admin/catalog/edit_tour/' . $tour->id, ' ', 'title="'. lang('buttons.edit').'" class="icon-1 info-tooltip"'); ?>
						<?php echo anchor('admin/catalog/dailyplans/' . $tour->id, ' ', 'title="'. lang('global:preview').'" class="icon-3 info-tooltip"'); ?>
						<?php endif; ?>
						<?php if (group_has_role('catalog', 'delete_tour')): ?>
						<a class="icon-2 info-tooltip" title="<?php echo lang('buttons.delete');?>" href="javascript:void(0);" onclick="if(confirm('<?php echo lang('global:delete')?>')){window.location.href='<?php echo site_url('admin/catalog/delete_tour/' . $tour->id);?>'}"></a>
						<?php endif; ?>
					</td>
				</tr>
				<?php endforeach;?>
				</tbody>
</table>
<input type="hidden" name="btnAction"  id="btnAction" value=""/>
<?php if (group_has_role('catalog', 'delete_tour')): ?>
<script type="text/javascript">
	function submit_form(type)
	{
		if('delete' == type){
			if(confirm('<?php echo lang("global:delete_confirm")?>')){
				$('#btnAction').val('delete');
				$('#mainform').submit();
			}
		}
	}
</script>
<div id="actions-box">
	<a href="" class="action-slider"></a>
	<div id="actions-box-slider">
		<a href="javascript:void(0);" onclick="submit_form('delete');" class="action-delete">Delete</a>
	</div>
	<div class="clear"></div>
</div>
<div align=center><div class="inner"><?php $this->load->view('partials/pagination'); ?></div></div>
<?php endif; ?>
<?php echo form_close();?>

<?php else: ?>
	<div class="no_data file-tours">
		<p><?php echo lang('tours.no_tour');?></p>
		<br />
		<p>[<a href="<?php echo site_url('admin/catalog/create_tour')?>"><?php echo lang('menu_2_catalog_create_tour')?></a>]</p>
	</div>
<?php endif; ?>